package com.chao.model;

import java.io.Serializable;

/**
 * @author Luck Chao
 * @Date: 2021/12/09
 */
public class HeaderContextHolder implements Serializable {

    private static final ThreadLocal<HeaderContext> headerContextThreadLocal = new ThreadLocal<>();

    public static HeaderContext get() {
        HeaderContext headerContext = headerContextThreadLocal.get();
        if (null == headerContext) {
            throw new RuntimeException("header上下文信息不存在！");
        }
        return headerContext;
    }

    public static void set(HeaderContext headerContext) {
        headerContextThreadLocal.set(headerContext);
    }

    public static void clear() {
        headerContextThreadLocal.remove();
    }

}
